home *** CD-ROM | disk | FTP | other *** search
/ CD Classic 39 / CD CLASSIC #39 (1998).iso / EMPRESA / visio / Vistdstd / Install / Data.Z / Mainwnd.FRM (.txt) < prev    next >
Visual Basic Form  |  1996-10-31  |  21KB  |  520 lines

  1. VERSION 4.00
  2. Begin VB.Form frmMainWindow 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H00C0C0C0&
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "Visio Inventory"
  7.    ClientHeight    =   6000
  8.    ClientLeft      =   3330
  9.    ClientTop       =   3720
  10.    ClientWidth     =   8535
  11.    BeginProperty Font 
  12.       name            =   "MS Sans Serif"
  13.       charset         =   0
  14.       weight          =   700
  15.       size            =   8.25
  16.       underline       =   0   'False
  17.       italic          =   0   'False
  18.       strikethrough   =   0   'False
  19.    EndProperty
  20.    ForeColor       =   &H80000008&
  21.    Height          =   6690
  22.    Icon            =   "MAINWND.frx":0000
  23.    Left            =   3270
  24.    LinkTopic       =   "Form2"
  25.    MaxButton       =   0   'False
  26.    ScaleHeight     =   6000
  27.    ScaleWidth      =   8535
  28.    Top             =   3090
  29.    Width           =   8655
  30.    Begin Threed.SSPanel ctlStatusLine 
  31.       Align           =   2  'Align Bottom
  32.       Height          =   375
  33.       Left            =   0
  34.       TabIndex        =   2
  35.       Top             =   5625
  36.       Width           =   8535
  37.       _Version        =   65536
  38.       _ExtentX        =   15055
  39.       _ExtentY        =   661
  40.       _StockProps     =   15
  41.       Caption         =   "Ready"
  42.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  43.          Name            =   "MS Sans Serif"
  44.          Size            =   8.25
  45.          Charset         =   0
  46.          Weight          =   400
  47.          Underline       =   0   'False
  48.          Italic          =   0   'False
  49.          Strikethrough   =   0   'False
  50.       EndProperty
  51.       BevelInner      =   1
  52.       RoundedCorners  =   0   'False
  53.       Font3D          =   3
  54.       Alignment       =   1
  55.    End
  56.    Begin VB.ComboBox ctlPageList 
  57.       Appearance      =   0  'Flat
  58.       Height          =   300
  59.       Left            =   1260
  60.       Style           =   2  'Dropdown List
  61.       TabIndex        =   4
  62.       Top             =   480
  63.       Width           =   2715
  64.    End
  65.    Begin VB.ComboBox ctlDocList 
  66.       Appearance      =   0  'Flat
  67.       Height          =   300
  68.       Left            =   1260
  69.       Style           =   2  'Dropdown List
  70.       TabIndex        =   3
  71.       Top             =   120
  72.       Width           =   2715
  73.    End
  74.    Begin VB.ComboBox ctlSortField 
  75.       Appearance      =   0  'Flat
  76.       Height          =   300
  77.       Left            =   1260
  78.       Style           =   2  'Dropdown List
  79.       TabIndex        =   1
  80.       Top             =   840
  81.       Width           =   2715
  82.    End
  83.    Begin Threed.SSPanel Panel3D1 
  84.       Height          =   5655
  85.       Left            =   0
  86.       TabIndex        =   5
  87.       Top             =   0
  88.       Width           =   8535
  89.       _Version        =   65536
  90.       _ExtentX        =   15055
  91.       _ExtentY        =   9975
  92.       _StockProps     =   15
  93.       BevelInner      =   1
  94.       Begin MSGrid.Grid ctlQueryGrid 
  95.          Height          =   4275
  96.          Left            =   120
  97.          TabIndex        =   0
  98.          Top             =   1200
  99.          Width           =   8235
  100.          _Version        =   65536
  101.          _ExtentX        =   14526
  102.          _ExtentY        =   7541
  103.          _StockProps     =   77
  104.          BackColor       =   -2147483643
  105.          Cols            =   9
  106.          FixedCols       =   0
  107.       End
  108.       Begin Threed.SSCommand btnReQuery 
  109.          Height          =   1035
  110.          Left            =   6780
  111.          TabIndex        =   10
  112.          Top             =   120
  113.          Width           =   1575
  114.          _Version        =   65536
  115.          _ExtentX        =   2778
  116.          _ExtentY        =   1826
  117.          _StockProps     =   78
  118.          Caption         =   "ReQuery Visio"
  119.          Picture         =   "MAINWND.frx":030A
  120.       End
  121.       Begin Threed.SSCommand btnChooseFields 
  122.          Height          =   1035
  123.          Left            =   5100
  124.          TabIndex        =   9
  125.          Top             =   120
  126.          Width           =   1575
  127.          _Version        =   65536
  128.          _ExtentX        =   2778
  129.          _ExtentY        =   1826
  130.          _StockProps     =   78
  131.          Caption         =   "Choose Fields"
  132.          Picture         =   "MAINWND.frx":0624
  133.       End
  134.       Begin VB.Label Label3 
  135.          Alignment       =   1  'Right Justify
  136.          Appearance      =   0  'Flat
  137.          BackColor       =   &H00C0C0C0&
  138.          Caption         =   "Sort Field:"
  139.          ForeColor       =   &H80000008&
  140.          Height          =   195
  141.          Left            =   300
  142.          TabIndex        =   7
  143.          Top             =   900
  144.          Width           =   915
  145.       End
  146.       Begin VB.Label Label2 
  147.          Alignment       =   1  'Right Justify
  148.          Appearance      =   0  'Flat
  149.          BackColor       =   &H00C0C0C0&
  150.          Caption         =   "Page:"
  151.          ForeColor       =   &H80000008&
  152.          Height          =   195
  153.          Left            =   420
  154.          TabIndex        =   8
  155.          Top             =   540
  156.          Width           =   795
  157.       End
  158.       Begin VB.Label Label1 
  159.          Alignment       =   1  'Right Justify
  160.          Appearance      =   0  'Flat
  161.          BackColor       =   &H00C0C0C0&
  162.          Caption         =   "Document:"
  163.          ForeColor       =   &H80000008&
  164.          Height          =   195
  165.          Left            =   180
  166.          TabIndex        =   6
  167.          Top             =   180
  168.          Width           =   1035
  169.       End
  170.       Begin VB.Shape Shape1 
  171.          BackColor       =   &H00000000&
  172.          BackStyle       =   1  'Opaque
  173.          Height          =   4275
  174.          Left            =   180
  175.          Top             =   1260
  176.          Width           =   8235
  177.       End
  178.    End
  179.    Begin VB.Menu FileMenu 
  180.       Caption         =   "&File"
  181.       Begin VB.Menu FileExport 
  182.          Caption         =   "&Export"
  183.          Shortcut        =   ^S
  184.       End
  185.       Begin VB.Menu FileSep 
  186.          Caption         =   "-"
  187.       End
  188.       Begin VB.Menu FilePrint 
  189.          Caption         =   "&Print"
  190.          Enabled         =   0   'False
  191.       End
  192.       Begin VB.Menu FilePrinterSetup 
  193.          Caption         =   "Pri&nter Setup"
  194.          Enabled         =   0   'False
  195.       End
  196.       Begin VB.Menu FilePageSetup 
  197.          Caption         =   "Page Se&tup"
  198.          Enabled         =   0   'False
  199.       End
  200.       Begin VB.Menu FileSep2 
  201.          Caption         =   "-"
  202.       End
  203.       Begin VB.Menu FileExit 
  204.          Caption         =   "E&xit"
  205.       End
  206.    End
  207.    Begin VB.Menu EditMenu 
  208.       Caption         =   "&Edit"
  209.       Begin VB.Menu EditCopy 
  210.          Caption         =   "&Copy"
  211.          Enabled         =   0   'False
  212.          Shortcut        =   ^{INSERT}
  213.       End
  214.       Begin VB.Menu EditSep1 
  215.          Caption         =   "-"
  216.       End
  217.       Begin VB.Menu EditSelectAll 
  218.          Caption         =   "&Select All"
  219.       End
  220.    End
  221.    Begin VB.Menu OptionsMenu 
  222.       Caption         =   "&Options"
  223.       Begin VB.Menu ExportSetup 
  224.          Caption         =   "E&xport Setup"
  225.       End
  226.    End
  227.    Begin VB.Menu HelpMenu 
  228.       Caption         =   "&Help"
  229.       Begin VB.Menu HelpContents 
  230.          Caption         =   "&Contents"
  231.          Enabled         =   0   'False
  232.          Shortcut        =   {F1}
  233.       End
  234.       Begin VB.Menu HelpSearch 
  235.          Caption         =   "&Search For Help On"
  236.          Enabled         =   0   'False
  237.       End
  238.       Begin VB.Menu HelpSep 
  239.          Caption         =   "-"
  240.       End
  241.       Begin VB.Menu HelpAbout 
  242.          Caption         =   "&About"
  243.       End
  244.    End
  245. Attribute VB_Name = "frmMainWindow"
  246. Attribute VB_Creatable = False
  247. Attribute VB_Exposed = False
  248. ' -----------------------------------------------------------------------------
  249. ' Copyright (C) 1993-1996 Visio Corporation. All rights reserved.
  250. ' You have a royalty-free right to use, modify, reproduce and distribute
  251. ' the Sample Application Files (and/or any modified version) in any way
  252. ' you find useful, provided that you agree that Visio has no warranty,
  253. ' obligations or liability for any Sample Application Files.
  254. ' -----------------------------------------------------------------------------
  255. Option Explicit                                 '-- All Variable Explicit
  256. Dim iSortIndex As Integer                       '-- Sort Field Index
  257. Dim iPageIndex As Integer                       '-- Current Page Index
  258. Dim iDocIndex As Integer                        '-- Current Document Index
  259.                                                                     
  260. Private Sub btnChooseFields_Click()
  261. '------------------------------------
  262. '--- btnChooseFields_Click ----------
  263. '--   When the Choose Fields is chosen we load the Choose Fields form.  After
  264. '-- It's done we re-paint the query grid to take into account any changes made.
  265.     frmChooseFields.Show 1
  266.     If Not GetIncludeFlag(iSortIndex) Then
  267.         iSortIndex = 0
  268.     End If
  269.     UpdateFieldsList
  270.     RePaint
  271. End Sub
  272. Private Sub btnReQuery_Click()
  273. '------------------------------------
  274. '--- btnReQuery_Click ---------------
  275. '--   When the user presses this button we just want to requery the database.
  276.   UpdateDatabase
  277. End Sub
  278. Private Sub ctlDocList_Click()
  279. '------------------------------------
  280. '--- ctlDocList_Click ---------------
  281. '--   When the user clicks a document name we check to see if it's different
  282. '-- than our internal index iDocIndex.  If so we update the page list and the
  283. '-- internal index.
  284.   If iDocIndex <> ctlDocList.ListIndex Then         '-- If Different Indexes...
  285.     iDocIndex = ctlDocList.ListIndex                '--   Update Internal Index
  286.     Call UpdatePageList                             '--   Update Page List
  287.   End If
  288. End Sub
  289. Private Sub ctlPageList_Click()
  290. '------------------------------------
  291. '--- ctlDocList_Change --------------
  292. '--   When the user clicks a page name we check to see if it's different
  293. '-- than our internal index iPageIndex.  If so we requery the database and
  294. '-- size the columns.
  295.   If iPageIndex <> ctlPageList.ListIndex Then
  296.     iPageIndex = ctlPageList.ListIndex          '-- Update Page Index
  297.     ReQuery CurDocIndex(), CurPageIndex()
  298.     RePaint
  299.   End If
  300. End Sub
  301. Private Sub ctlQueryGrid_SelChange()
  302. '------------------------------------
  303. '--- ctlQueryGrid_SelChange ---------
  304.     If (ctlQueryGrid.SelEndCol >= ctlQueryGrid.SelStartCol) Then
  305.         If (ctlQueryGrid.SelEndRow >= ctlQueryGrid.SelStartRow) Then
  306.             EditCopy.Enabled = True
  307.             Exit Sub
  308.         End If
  309.     End If
  310.     EditCopy.Enabled = False
  311. End Sub
  312. Private Sub ctlSortField_Click()
  313. '------------------------------------
  314. '--- cstSortField_Click -------------
  315. '--   When the user clicks a sort field name we check to see if it's different
  316. '-- than our internal index iSortIndex.  If so we process the change and update
  317. '-- the internal index.
  318.   If iSortIndex <> ctlSortField.ListIndex Then
  319.     iSortIndex = ctlSortField.ListIndex
  320.     SetSort iSortIndex
  321.     RePaint
  322.   End If
  323. End Sub
  324. Private Function CurDocIndex() As Integer
  325. '------------------------------------
  326. '--- CurDocIndex --------------------
  327. '--   Simply returns the collection index of the current document.  Note, it
  328. '-- returns the collection index, not the control index.
  329.   Dim iIndex As Integer
  330.   iIndex = ctlDocList.ListIndex
  331.   CurDocIndex = GetCollIndex(iIndex)
  332. End Function
  333. Private Function CurPageIndex() As Integer
  334. '------------------------------------
  335. '--- CurPageIndex -------------------
  336. '--   Simply returns the index of the current page.  However, it returns the
  337. '-- collection index, not the page controls index.
  338.   CurPageIndex = ctlPageList.ListIndex + 1       '-- Return Index
  339. End Function
  340. Private Sub EditCopy_Click()
  341. '------------------------------------
  342. '--- EditCopy_Click -----------------
  343. '--   Copies the highlighted selection on the grid to the clipboard.
  344.     Dim iRow As Integer, iCol As Integer, Temp As String
  345.     Dim iOldRow As Integer, iOldCol As Integer
  346.     Dim sFieldSep As String
  347.     sFieldSep = g_FieldSeps(g_iFieldSepIdx)
  348.     iOldRow = ctlQueryGrid.Row                  '-- Save Last Row And Column
  349.     iOldCol = ctlQueryGrid.Col
  350.     If g_bIncFieldNames Then                    '-- Include Field Names
  351.         ctlQueryGrid.Row = 0                    '-- Move To Field Row
  352.         For iCol = ctlQueryGrid.SelStartCol To ctlQueryGrid.SelEndCol
  353.             ctlQueryGrid.Col = iCol
  354.             If iCol <> ctlQueryGrid.SelStartCol Then
  355.                 Temp = Temp + sFieldSep
  356.             End If
  357.             Temp = Temp + ApplyTextDel(ctlQueryGrid.Text)
  358.         Next iCol
  359.         Temp = Temp + Chr$(13) + Chr$(10)       '-- Append CR/LF
  360.     End If
  361.     For iRow = ctlQueryGrid.SelStartRow To ctlQueryGrid.SelEndRow
  362.         ctlQueryGrid.Row = iRow
  363.         For iCol = ctlQueryGrid.SelStartCol To ctlQueryGrid.SelEndCol
  364.             ctlQueryGrid.Col = iCol
  365.             If iCol <> ctlQueryGrid.SelStartCol Then
  366.                 Temp = Temp + sFieldSep
  367.             End If
  368.             Temp = Temp + ApplyTextDel(ctlQueryGrid.Text)
  369.         Next iCol
  370.         Temp = Temp + Chr$(13) + Chr$(10)       '-- Append CR/LF
  371.     Next iRow
  372.     ctlQueryGrid.Row = iOldRow                  '-- Restore Last Row And Column
  373.     ctlQueryGrid.Col = iOldCol
  374.     Clipboard.Clear                             '-- Clear Clipboard Contents
  375.     Clipboard.SetText Temp                      '-- Put Text On Clipboard
  376. End Sub
  377. Private Sub EditSelectAll_Click()
  378. '------------------------------------
  379. '--- EditSelectAll_Click ------------
  380. '--   Selects all data on the grid.
  381.     ctlQueryGrid.SelStartCol = ctlQueryGrid.FixedCols
  382.     ctlQueryGrid.SelStartRow = ctlQueryGrid.FixedRows
  383.     ctlQueryGrid.SelEndCol = ctlQueryGrid.Cols - 1
  384.     ctlQueryGrid.SelEndRow = ctlQueryGrid.Rows - 1
  385. End Sub
  386. Private Sub ExportSetup_Click()
  387. '------------------------------------
  388. '--- ExportSetup_Click --------------
  389. '--   Displays the export setup dialog.
  390.     frmExportSetup.Show 1
  391. End Sub
  392. Private Sub FileExit_Click()
  393. '------------------------------------
  394. '--- FileExit_Click -----------------
  395. '--   When the user chooses to quit we unload the main form and end.
  396.   Unload frmMainWindow                          '-- Unload Main Frame
  397.   End                                           '-- End Program
  398. End Sub
  399. Private Sub FileExport_Click()
  400. '------------------------------------
  401. '--- FileExport_Click ---------------
  402.     On Error GoTo ExportErrHandler
  403.     Dim Temp As String
  404.     Const OFN_HIDEREADONLY = &H4&
  405.     Const OFN_OVERWRITEPROMPT = &H2&
  406.     frmSaveAs.CMDialog1.CancelError = True
  407.     frmSaveAs.CMDialog1.Flags = OFN_HIDEREADONLY Or OFN_OVERWRITEPROMPT
  408.     frmSaveAs.CMDialog1.Action = 2
  409.     Temp = frmSaveAs.CMDialog1.filename
  410.     ExportToFile Temp
  411.     Exit Sub
  412. ExportErrHandler:
  413.     Exit Sub
  414.     Resume Next
  415. End Sub
  416. Private Sub Form_Activate()
  417. '------------------------------------
  418. '--- frmMainWindow:Form_Activate ----
  419. '--   When the window is activated we always update the database in case the
  420. '-- user has made any changes in Visio.  Need to add a flag to not update after
  421. '-- internal form changes.
  422.   'Remmed by TDS - must check for internal activates (i.e. About form unloaded)
  423.   'UpdateDatabase                                '-- Update Database Lists
  424. End Sub
  425. Private Sub Form_Load()
  426. '------------------------------------
  427. '--- frmMainWindow:Form_Load --------
  428. '--   Handles application initialization.  All we do at first is update the
  429. '-- field list.  The document and page lists should be handled by the window
  430. '-- Activate event.
  431.   iSortIndex = 0                                '-- Default To Name Sort
  432.   iDocIndex = -1                                '-- Default To No Doc
  433.   iPageIndex = -1                               '-- Default To No Page
  434.   EditCopy.Enabled = False                      '-- Disable Copy Option
  435.   InitExportOptions                             '-- Initialize Export Vars
  436.   UpdateFieldsList                              '-- Update Sort Field List
  437. End Sub
  438. Private Sub Form_Unload(Cancel As Integer)
  439.     End
  440. End Sub
  441. Private Sub HelpAbout_Click()
  442.   frmAboutDialog.Show 1                             '-- Show Help About
  443. End Sub
  444. Private Sub UpdateDatabase()
  445. '------------------------------------
  446. '--- UpdateDatabase -----------------
  447. '--   Updates the internal database of valid Visio document which are loaded.
  448. '-- Should be called whenever the focus is set or application is activated to
  449. '-- make sure the controls reflect Visio's open documents.  Only call
  450. '-- UpdateDocList because it's click event updates the page list anyways.
  451.   StatusLineMsg "Querying Visio Documents..."
  452.   UpdateValidDocList                            '-- Update Valid Documents
  453.   StatusLineMsg "Updating Document List..."
  454.   UpdateDocList                                 '-- Update Document List Box
  455.   ClearStatusLine
  456. End Sub
  457. Private Sub UpdateDocList()
  458. '------------------------------------
  459. '--- UpdateDocList ------------------
  460. '--   Handles updating the document drop down list on the main form.  Uses the
  461. '-- Valid Document Interface for retrieving document names.  By setting
  462. '-- the list box index we guarantee a Click event will occur and iDocIndex
  463. '-- to be updated by the boxes Click handler.  When this happens it chains
  464. '-- down to the page list as well.
  465.   Dim I As Integer
  466.   iDocIndex = -1                                  '-- Force ReQuery
  467.   ctlDocList.Clear                                '-- Clear Document List
  468.   StatusLineMsg "Updating Document List..."       '-- Update Status Line
  469.   If DocCount() > 0 Then                          '-- Any Documents...
  470.     For I = 0 To DocCount() - 1                   '--   Loop Through Docs...
  471.       ctlDocList.AddItem StripPath(GetDocName(I)) '--     Add Name
  472.     Next I
  473.                                                 
  474.     ctlDocList.ListIndex = 0                      '--   Select First Document
  475.                                                   '--     And Get
  476.   Else
  477.     ctlDocList.ListIndex = -1                     '--   No Doc Selected
  478.   End If
  479.   ClearStatusLine                                   '-- Clear Status Line
  480. End Sub
  481. Private Sub UpdateFieldsList()
  482. '------------------------------------
  483. '--- UpdateFieldsList ---------------
  484. '--   Fills in the main form's Sort Field list box.
  485.   Dim I As Integer
  486.   ctlSortField.Clear                            '-- Clear List
  487.   For I = 0 To IncludeCount() - 1               '-- Loop Through Used Fields...
  488.     ctlSortField.AddItem IncludeNames(I)        '--   Add Next Field Name
  489.   Next I
  490.   ctlSortField.ListIndex = 0                    '-- Select First Field
  491. End Sub
  492. Private Sub UpdatePageList()
  493. '------------------------------------
  494. '--- UpdatePageList -----------------
  495. '--   Updates the page drop down list names.  Uses the Valid Document Interface
  496. '-- to retrieve the current document.  By setting the page index to -1 we force
  497. '-- a requery when the list box's Click handler gets called.
  498.   Dim I As Integer, iPageCount As Integer, iCurDoc As Integer
  499.   Dim pagsPageList As Visio.Pages, docCurDoc As Visio.DOCUMENT
  500.   iPageIndex = -1                                   '-- Force ReQuery
  501.   ctlPageList.Clear                                 '-- Clear Page List
  502.   iCurDoc = ctlDocList.ListIndex                    '-- Get Current Doc Index
  503.   If iCurDoc = -1 Then Exit Sub                     '-- If No Document Exit
  504.   StatusLineMsg "Updating Page List..."             '-- Updating Page List
  505.   iCurDoc = GetCollIndex(iCurDoc)                   '-- Get Collection Index
  506.   AppConnect
  507.   Set docCurDoc = g_appVisio.Documents(iCurDoc)     '-- Get Current Document
  508.   iPageCount = docCurDoc.Pages.Count                '-- Get Page Count
  509.   If iPageCount > 0 Then                            '-- Any Documents....
  510.     Set pagsPageList = docCurDoc.Pages              '--   Get Page List
  511.     For I = 1 To iPageCount                         '--   Loop Through Pages...
  512.       ctlPageList.AddItem pagsPageList(I).Name      '--     Add Name
  513.     Next I
  514.     ctlPageList.ListIndex = 0                       '-- Set To Active Doc
  515.   Else
  516.     ctlPageList.ListIndex = -1                      '-- No Selection
  517.   End If
  518.   ClearStatusLine                                   '-- Clear Status Line
  519. End Sub
  520.